package elitech.vietnam.myfashion.dialog;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;

public class MyDialogHandler {

	public Runnable ans_true = null;
	public Runnable ans_false = null;

	// Dialog. --------------------------------------------------------------

	public boolean confirm(Context act, String Title, String ConfirmText,
			String CancelBtn, String OkBtn, Runnable okProcedure,
			Runnable cancelProcedure) {
		ans_true = okProcedure;
		ans_false = cancelProcedure;
		AlertDialog dialog = new AlertDialog.Builder(act).create();
		dialog.setTitle(Title);
		dialog.setMessage(ConfirmText);
		dialog.setCancelable(false);
		dialog.setButton(DialogInterface.BUTTON_POSITIVE, OkBtn,
				new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int buttonId) {
						if (ans_true != null)
							ans_true.run();
					}
				});
		dialog.setButton(DialogInterface.BUTTON_NEGATIVE, CancelBtn,
				new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int buttonId) {
						if (ans_false != null)
							ans_false.run();
					}
				});
		dialog.setIcon(android.R.drawable.ic_dialog_alert);
		dialog.show();
		return true;
	}
}
